package com.example.admin.goodnews.fragment.ReSouXinWen;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.admin.goodnews.R;
import com.example.admin.goodnews.adapter.FragmentAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * 热搜新闻页面
 * Created by admin on 2016/10/10.
 */

public class ReSouXinWenFragment extends Fragment {
    private TabLayout tablayout_resouxinwen;// 标题栏
    private ViewPager viewpager_resouxinwen;// 加载内容的容器
    private List<String> tablists = new ArrayList<>();
    private List<Fragment> fragmentlists = new ArrayList<>();
    private FragmentAdapter fragmentAdapter;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_hotnews, null);
        tablayout_resouxinwen = (TabLayout) view.findViewById(R.id.tablayout_resouxinwen);// 标题栏
        viewpager_resouxinwen = (ViewPager) view.findViewById(R.id.viewpager_resouxinwen);// 加载内容的容器
        initData();
        initEvent();
        return view;
    }

    private void initData() {
        tablists.add("本周热搜新闻");
        tablists.add("实时热搜新闻");
        fragmentlists.add(new BenZhouReSouFragment());
        fragmentlists.add(new ShiShiReSouFragment());
        fragmentAdapter = new FragmentAdapter(getActivity().getSupportFragmentManager(), tablists, fragmentlists);
        viewpager_resouxinwen.setAdapter(fragmentAdapter);
        tablayout_resouxinwen.setupWithViewPager(viewpager_resouxinwen);
    }

    private void initEvent() {

    }

}
